home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c++-part1 / 8084 < prev    next >
Encoding:
Internet Message Format  |  1996-08-05  |  1.0 KB

  1. Path: news.ld.centuryinter.net!usenet
  2. From: steidl@centuryineter.net
  3. Newsgroups: comp.lang.c++
  4. Subject: Re: Overloading operator [][] as in A[][]: possible?!
  5. Date: 14 Feb 1996 12:37:55 GMT
  6. Organization: Century Internet    
  7. Message-ID: <4fsl33$maf@news.ld.centuryinter.net>
  8. References: <311F6E92.794BDF32@cenparmi.concordia.ca>
  9. Reply-To: steidl@centuryineter.net
  10. NNTP-Posting-Host: anx_p12.wi.centuryinter.net
  11. X-Newsreader: IBM NewsReader/2 v1.2
  12.  
  13. In <311F6E92.794BDF32@cenparmi.concordia.ca>, Didier Guillevic <didier@cenparmi.concordia.ca> writes:
  14. >Bonjour,
  15. >
  16. >Learning C++ at the moment....
  17. >Any way to overload the indexing of a 2 dimensional array, as in
  18. >
  19. >  A[i][j]
  20.  
  21. It can be done using an intermediary class.  For example, class A's operator[]
  22. returns a class B object.  A class B object contains a reference to the class A
  23. object and the parameter passed in the first [].  Class B's operator[] then
  24. gets the second parameter.  It looks pretty (if you think C array notation is
  25. pretty) buts it's not very efficient (either code-size-wise or speed-wise).
  26.  
  27.